package org.saxion.aktiehuis.DAO;

import java.util.List;

import org.hibernate.Query;
import org.hibernate.Session;
import org.hibernate.SessionFactory;
import org.saxion.aktiehuis.DAO.interfaces.ProductDAO;
import org.saxion.aktiehuis.model.Product;
import org.saxion.aktiehuis.model.ProductSoort;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import org.springframework.transaction.annotation.Transactional;

public class ProductMock extends HibernateDaoSupport implements ProductDAO {

//	private SessionFactory sessionFactory;
//
//	public void setSessionFactory(SessionFactory sessionFactory) {
//		this.sessionFactory = sessionFactory;
//	}

	public List<Product> getProducten(ProductSoort productSoort) throws Exception {
		Session session = getSession(true);
		List<Product> producten = null;
		try {
			producten = session
					.createQuery("from Product p WHERE p.productsoort = :productsoort")
					.setParameter("productsoort", productSoort)
					.list();
		} catch (Exception ex) {
			throw ex;
		}
		
		return producten;
	}

	public List<Product> getProducten() throws Exception {
		Session session = getSession(true);
		List<Product> producten = null;
		try {
			producten = session.createQuery("from Product").list();

		} catch (Exception ex) {
			throw ex;
		}
		
		return producten;

	}


}
